import { fallbackRequestGet } from '@/utils/Request'

/**
 * 请求前缀，后面后台添加网关后需要前缀选择微服务
 */
const URL_PREFIX = 'middle-goods/'

/**
 * 收藏商品
 * @param {Number, String} id 商品id
 * @param {Function} successCallback 成功回调，参数为data
 * @param {Function} fullCallback 肯定触发的回调，先于callback
 */
export const addEnshrineGood = (id, successCallback = null, fullCallback = null) => {
  return fallbackRequestGet(URL_PREFIX + 'enshrine-goods/addEnshrineGood', { id }, {}, true, data => {
    if (successCallback) {
      successCallback(data)
    }
  }, null, fullCallback)
}

/**
 * 查询所有收藏商品收藏商品
 * @param {Function} successCallback 成功回调，参数为data
 * @param {Function} fullCallback 肯定触发的回调，先于callback
 */
export const queryAllEnshrineGoods = (successCallback = null, fullCallback = null) => {
  return fallbackRequestGet(URL_PREFIX + 'enshrine-goods/queryAllEnshrineGoods', {}, {}, true, data => {
    if (successCallback) {
      successCallback(data)
    }
  }, null, fullCallback)
}

/**
 * 查询所有收藏商品收藏商品，返回商品详细信息
 * @param {Function} successCallback 成功回调，参数为data
 * @param {Function} fullCallback 肯定触发的回调，先于callback
 */
export const queryAllEnshrineConvertGoods = (successCallback = null, fullCallback = null) => {
  return fallbackRequestGet(URL_PREFIX + 'enshrine-goods/queryAllEnshrineConvertGoods', {}, {}, false, data => {
    if (successCallback) {
      successCallback(data)
    }
  }, null, fullCallback)
}
